import axios from "axios";
import { AxiosRequestConfig } from "axios";
import { setupInterceptors } from "@/axios/HttpInterceptors";
import Setting from "@/common/constants/Settings";
// import { store } from "@/common/stores";

const ServerRouterSetting: AxiosRequestConfig = {
  baseURL: Setting.ServerRouterBaseUrl,
  timeout: 60000,
  headers: {
    "Content-Type": "application/json",
  },
};

export const ServerRouteHttpClient = axios.create(ServerRouterSetting);

export function updateHttpSetting(url: string) {
  const HttpSetting = {
    baseURL: url,
    timeout: 60000,
    headers: {
      "Content-Type": "application/json",
    },
  };
  HttpClient = axios.create(HttpSetting);
  setupInterceptors();
}

export let HttpClient = axios.create(ServerRouterSetting);
